<?php
namespace api\mall\controller;
use cmf\controller\RestBaseController;
// use api\mall\model\PortalPostModel;

/**
 * @OA\Tag(
 *     name="mall-system",
 *     description="配置信息"
 * )
 */
class SystemController extends RestBaseController{

    /**
     * 用户协议
     * @OA\Get(
     *     tags={"mall-system"},
     *     path="/mall/system/userAgreement",
     *     @OA\Response(response=200, ref="#/components/responses/200")
     * )
     */
    public function userAgreement() {
        // $portalPostModel = new PortalPostModel();
        // $data = $portalPostModel->where('id', 1)->find();
        // $this->success('ok', $data['post_content']);
        $data['url'] = '/agreement.html';
        $this->success('ok', $data);
    }

    /**
     * 隐私条款
     * @OA\Get(
     *     tags={"mall-system"},
     *     path="/mall/system/privacyPolicy",
     *     @OA\Response(response=200, ref="#/components/responses/200")
     * )
     */
    public function privacyPolicy() {
        // $portalPostModel = new PortalPostModel();
        // $data = $portalPostModel->where('id', 2)->find();
        // $this->success('ok', $data['post_content']);
        $data['url'] = '/privacy.html';
        $this->success('ok', $data);
    }

    /**
     * 获取配置信息
     * @OA\Get(
     *     tags={"mall-system"},
     *     path="/mall/system/get_config",
     *     @OA\Response(response=200, ref="#/components/responses/200")
     * )
     */
    public function get_config(){
        $cache = cmf_get_option('res_config');
        $cfg = [
            'ver'=>'0.1',
            'res_ver'=>['models'=>1, 'dressup'=>1, 'spaces'=>1, 'views'=>1],
            'res_path'=>'http://metamall-1314752903.cos.ap-beijing.myqcloud.com/',
            'server'=>'http://82.156.218.190'
        ];
        if($cache){
            $cfg['res_ver']=$cache;
        }
        $this->success('ok',$cfg);
    }
}